// 手写flowRight
const reverse = (array) => array.reverse();
const first = (array) => array[0];
const toUpper = (value) => value.toUpperCase();

// function compose(...args) {
//   return function (value) {
//     return args.reverse().reduce(function (pre, item) {
//       return item(pre);
//     }, value);
//   };
// }

// es6
const compose=(...args)=>(value)=>args.reverse().reduce((pre,item)=>item(pre),value);

const f = compose(toUpper, first, reverse);
console.log(f(["one","two","three"])); 
